<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新增项目</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layui/layuiAdmin/css/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">新增项目</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form-item">
                        <label class="layui-form-label">项目id</label>
                        <div class="layui-input-inline">
                            <input type="text" id="id" lay-verify="nickname" autocomplete="off" placeholder="请输入id"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="payProjectName" autocomplete="off" class="layui-input"
                                   placeholder="请输入名称">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">项目价格</label>
                        <div class="layui-input-inline">
                            <input type="text" id="payProjectPrice" placeholder="请输入价格" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">添加时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="payProjectDate" placeholder="请选择时间" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">项目简述</label>
                        <div class="layui-input-inline">
                            <input type="text" id="payProjectContent" placeholder="请输入简述" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-filter="setmyinfo">确认增加</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</div>

<script src="../../layui/layui.js"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#payProjectDate' //指定元素
        });
    });

    $('.layui-btn').click(function () {
        // 获取表单数据
        // 获取表单数据
        var payProjectData = {
            "id": $("#id").val(),
            "payProjectName": $("#payProjectName").val(),//
            "payProjectPrice": $("#payProjectPrice").val(),
            "payProjectDate": $("#payProjectDate").val(),
            "payProjectContent": $("#payProjectContent").val()
        };
        // 将JSON对象转换为字符串
        var jsonData = JSON.stringify(payProjectData);
        // 发送 POST 请求到后端接口
        $.ajax({
            url: '/payProject/insertPayProject',
            type: 'POST',
            data: jsonData,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                // 请求成功后的处理逻辑
                alert("添加成功");
                console.log(error);
            },
            error: function (error) {
                // 请求失败后的处理逻辑
                alert("添加失败");
                console.log(error);
            }
        });
    });
</script>
</body>
</html>